package vivek.project.pocketmoney.expenses.model
{
	import vivek.project.pocketmoney.admin.model.AdminConstants;
	import vivek.project.pocketmoney.common.utils.CommonConstants;
	import vivek.project.pocketmoney.common.utils.StringUtils;

	public class ICICIBankLoader extends AccountLoaderImpl
	{
		private static var iciciBankLoader:ICICIBankLoader=null;

		private const delimiter:String="\t";

		private const numCols:int=9;

		private const dataStart:int=10;

		private const bankName:String="ICICI";

		public function ICICIBankLoader()
		{
			dateFormat="DD/MM/YYYY";
			categoryMatch.push({matchString: "ECS", catid: 43});
			categoryMatch.push({matchString: "EBA/MF", catid: 11});
			categoryMatch.push({matchString: "Interest", catid: 43});
			categoryMatch.push({matchString: "Interest", catid: 29});
			categoryMatch.push({matchString: "int", catid: 29});
			categoryMatch.push({matchString: "EBA/NSE", catid: 10});
		}

		public static function getInstance():ICICIBankLoader
		{
			if (iciciBankLoader == null)
				iciciBankLoader=new ICICIBankLoader();
			return iciciBankLoader;
		}

		override public function checkValiditiy(fileContent:String):Boolean
		{
			return false;
		}

		override public function getExpenseRecords(fileContent:String, account:Object):Array
		{
			var txnrecords:Array;
			var txntype:int=CommonConstants.WITHDRAWAL;
			var amount:Number=0;
			txnrecords=loadExpenseData(fileContent, delimiter, numCols);
			var expenseRecords:Array=new Array();
			for each (var obj:Object in txnrecords)
			{
				if (StringUtils.trimSpecialChar(obj[6]) == "Dr")
					txntype=CommonConstants.WITHDRAWAL;
				else
					txntype=CommonConstants.DEPOSIT;
				try
				{
					var expenseRecord:Object=new Object();
					amount=new Number(StringUtils.trimSpecialChar(obj[7]));
					expenseRecord=createExpenseObject(obj[2], amount, obj[5], txntype, account.am_accountid, 24, obj[4]);
					expenseRecords.push(expenseRecord);
				}
				catch (error:Error)
				{
				}
			}
			return expenseRecords;
		}
	}
}